package com.leilei.entity;

public class Page {

    private int currentPage;  //当前页
    private int pageSize;   //页面最大行数
    private int count;  //总记录数
    private int maxPage;    //最大页数
    private int startRows;  //起始行

    public Page() {
        this(1);
    }

    public Page(int currentPage) {
        this(currentPage, 5);
    }

    public Page(int currentPage, int pageSize) {
        setCurrentPage(currentPage);
        setPageSize(pageSize);
        setStartRows((this.currentPage - 1) * this.pageSize);
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage < 1 ? 1 : currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize <= 1 ? 5 : pageSize;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getMaxPage() {
        return maxPage;
    }

    public void setMaxPage(int maxPage) {
        this.maxPage = maxPage;
    }

    public int getStartRows() {
        return startRows;
    }

    public void setStartRows(int startRows) {
        this.startRows = startRows;
    }

    @Override
    public String toString() {
        return "Page{" +
                "currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", count=" + count +
                ", maxPage=" + maxPage +
                ", startRows=" + startRows +
                '}';
    }

}
